package com.atguigu.tingshu.order.interceptor.impl;

import com.alibaba.fastjson.JSON;
import com.atguigu.tingshu.common.constant.SystemConstant;
import com.atguigu.tingshu.order.helper.SignHelper;
import com.atguigu.tingshu.order.interceptor.OrderHandlerInterceptor;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

// 数据合法性校验任务类
@Service
@Slf4j
public class ValidDataOrderHandlerInterceptor implements OrderHandlerInterceptor {

    @Override
    public OrderInfoVo sbumitOrderRequestProcess(OrderInfoVo orderInfoVo) {
        log.info("ValidDataOrderHandlerInterceptor....");
        // 将数据转换为Map
        Map map = JSON.parseObject(JSON.toJSONString(orderInfoVo), Map.class);
        map.put("payWay", SystemConstant.ORDER_PAY_WAY_WEIXIN);//判断支付类型是否为微信支付
        SignHelper.checkSign(map);
        return orderInfoVo;
    }

    @Override
    public int sort() {
        return 1;
    }

}